package com.xwyzsn.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xwyzsn.common.annotation.Log;
import com.xwyzsn.common.core.controller.BaseController;
import com.xwyzsn.common.core.domain.AjaxResult;
import com.xwyzsn.common.enums.BusinessType;
import com.xwyzsn.system.domain.DeviceLocation;
import com.xwyzsn.system.service.IDeviceLocationService;
import com.xwyzsn.common.utils.poi.ExcelUtil;
import com.xwyzsn.common.core.page.TableDataInfo;

/**
 * 设备位置Controller
 * 
 * @author ruoyi
 * @date 2024-03-21
 */
@RestController
@RequestMapping("/system/location")
public class DeviceLocationController extends BaseController
{
    @Autowired
    private IDeviceLocationService deviceLocationService;

    /**
     * 查询设备位置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DeviceLocation deviceLocation)
    {
        startPage();
        List<DeviceLocation> list = deviceLocationService.selectDeviceLocationList(deviceLocation);
        return getDataTable(list);
    }

    /**
     * 导出设备位置列表
     */
    @Log(title = "设备位置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceLocation deviceLocation)
    {
        List<DeviceLocation> list = deviceLocationService.selectDeviceLocationList(deviceLocation);
        ExcelUtil<DeviceLocation> util = new ExcelUtil<DeviceLocation>(DeviceLocation.class);
        util.exportExcel(response, list, "设备位置数据");
    }

    /**
     * 获取设备位置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deviceLocationService.selectDeviceLocationById(id));
    }

    /**
     * 新增设备位置
     */
    @Log(title = "设备位置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceLocation deviceLocation)
    {
        return toAjax(deviceLocationService.insertDeviceLocation(deviceLocation));
    }

    /**
     * 修改设备位置
     */
    @Log(title = "设备位置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceLocation deviceLocation)
    {
        return toAjax(deviceLocationService.updateDeviceLocation(deviceLocation));
    }

    /**
     * 删除设备位置
     */
    @Log(title = "设备位置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceLocationService.deleteDeviceLocationByIds(ids));
    }
}
